package com.ps.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ps.property.TOtherCollect;
import com.ps.service.CollectService;
import com.ps.store.CollectStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author gt
 * @类说明：
 * @date 2020/10/27 19:23
 */
@Service
public class CollectServiceImpl implements CollectService {
    @Autowired
    CollectStore collectStore;

    @Override
    public int collectAdd(TOtherCollect tOtherCollect) {
        return collectStore.insert(tOtherCollect);
    }

    @Override
    public IPage<TOtherCollect> collectQuery(int currentPage, int pageSize) {
        IPage<TOtherCollect> iPage = new Page(currentPage,pageSize);

        iPage = collectStore.selectPage(iPage,null);

        return iPage;
    }

    @Override
    public TOtherCollect collectQueryById(int collectId) {
        QueryWrapper queryWrapper = new QueryWrapper();

        queryWrapper.eq("collect_id",collectId);

        return collectStore.selectOne(queryWrapper);
    }

    @Override
    public int collectUpdate(TOtherCollect tOtherCollect) {
        return collectStore.updateById(tOtherCollect);
    }

    /**
     * 根据id修改状态
     * @param collectId
     * @param status
     * @return
     */
    @Override
    public int collectUpdateByStatus(int collectId, String status) {
        return collectStore.collectUpdateByStatus(collectId,status);
    }
}
